/*
 * @Author: Hp_lucky 1063512385@qq.com
 * @Date: 2024-09-24 14:40:08
 * @LastEditors: Hp_lucky 1063512385@qq.com
 * @LastEditTime: 2024-10-16 20:16:58
 * @FilePath: \lucky-rpg\assets\script\src\Basic\Model\Platform\MultiPlatform.ts
 */
/* eslint-disable */
import { _decorator } from 'cc';
import WXPlatform from './WXPlatform';
import TTPlatform from './TTPlatform';
import { Singleton } from '../../Manager/BaseManager';
import { H5Platform } from './H5Platform';
import PlatformBase from './PlatformBase';
// import { constD } from '../common/ConstData';

/** 平台枚举 */
export enum Platform {
  /** 微信小游戏 */
  wx = 'wechat',
  /** 字节小游戏 */
  tt = 'douyin',
  /** h5小游戏 */
  h5 = 'pc',
}

/** 多平台控制器 */
export class MultiPlatform extends Singleton {
  className: string = 'MultiPlatform';
  platform: Platform;
  platformUnit: PlatformBase;

  AppKey: string = '652fa07058a9eb5b0af1b585';

  platformInit(p: Platform) {
    this.platform = p;
    switch (this.platform) {
      case Platform.wx:
        this.platformUnit = new WXPlatform();
        break;
      case Platform.tt:
        this.platformUnit = new TTPlatform();
        break;
      default:
        this.platformUnit = new H5Platform();
        break;
    }
    this.platformUnit.initFramework();
  }

  platformSelect() {
    // let platformYM = null;
    if (window['tt']) {
      console.log('tt');
      this.platformInit(Platform.tt);
    } else if (window['qq']) {
    } else if (window['xm']) {
    } else if (window['wx']) {
      console.log('wx');
      this.platformInit(Platform.wx);
    } else if (window['qg']) {
    } else {
      console.log('h5');
      this.platformInit(Platform.h5);
    }
  }
}
